package com.midian.common.interceptor;

import java.io.File;

import com.midian.action.mc.common.BaseAction;
import com.opensymphony.xwork2.ActionInvocation;
import com.opensymphony.xwork2.interceptor.MethodFilterInterceptor;

/**
 * 删除文件拦截器
 * @author Mengfh
 *
 */
public class DeletFileInterceptor extends MethodFilterInterceptor{

	@Override
	protected String doIntercept(ActionInvocation invocation) throws Exception {
		String retStr = invocation.invoke();
		
		Object action = invocation.getAction();
		if(action instanceof BaseAction){
			File file = (File) action.getClass().getMethod("getTargetFile").invoke(action);
			if (file != null && file.isFile()) {
				file.delete();
			}
		}
		return retStr;
	}
}
